package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "DonViTinh")
public class MeasureUnit {

	private int id;
	private String unitName;
	private int status;
	private Set<Medicament> medicaments = new HashSet<Medicament>(); 
	
	@OneToMany(mappedBy = "measure", fetch = FetchType.LAZY) 
	@Fetch(FetchMode.JOIN)
    public Set<Medicament> getMedicaments() {
		return medicaments;
	}
  
	public void setMedicaments(Set<Medicament> medicaments) {
		this.medicaments= medicaments;
	}
		
	@Id
	@GeneratedValue
	@Column(name = "MaDVT")
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="TenDVT")
	public String getUnitName() {
		return unitName;
	}
	
	public void setUnitName(String unitName) {
		this.unitName = unitName;
	}	
	@Column(name ="TrangThai")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
}
